<template>
  <div class="page adaofu-exchange-history">
    <div class="container" :style="bg">
      <div class="main">
        <div class="main-title">
          <div class="title">兑换历史</div>
        </div>
        <div class="main-content" v-if="exchangeList.length > 0">
          <exchange-list v-for="(item, i) in exchangeList" :key="i" :item="item"></exchange-list>
        </div>
        <div class="empty-tips" v-if="showEmptyTips">暂无兑换记录</div>
      </div>
    </div>
  </div>
</template>

<script>
import mixins from 'comp/mixins'
import { sourceDomain } from '@/utils/constant'
import ExchangeList from 'comp/exchange-list'

export default {
  mixins: [mixins],
  components: {
    ExchangeList
  },
  data () {
    return {
      icons: {
        bg: `${sourceDomain}/bg9.png`,
      },
      exchangeList: [],
      showEmptyTips: false
    }
  },
  computed: {
    bg () {
      return `background-image: url(${this.icons.bg});`
    },
  },
  mounted () {
    this.resetData()
    this.getExchangeList()
  },
  methods: {
    async getExchangeList () {
      const ret = await this.$store.dispatch('getExchangeList', {
        page: 1,
        rows: 30
      })
      this.exchangeList = ret.data.list
      if (this.exchangeList.length === 0) {
        this.showEmptyTips = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.adaofu-exchange-history {
  .container {
    position: relative;
    min-height: 100%;
    min-height: 100vh;
    background-size: 100% auto;
    background-repeat: no-repeat;
    background-position: center center;
  }
  .main {
    width: calc(100% - 268rpx);
    position: absolute;
    top: 50%;
    margin-top: -411rpx;
    margin-left: 118rpx;
    &-title {
      text-align: center;
      .title {
        color: #2f1a0e;
        font-size: 31rpx;
        font-weight: bold;
      }
    }
    &-content {
      margin-top: 25rpx;
      height: 710rpx;
      overflow: scroll;
    }
    .empty-tips {
      color: #999;
      font-size: 27rpx;
      text-align: center;
      padding-top: 30rpx;
    }
  }
}
</style>
